const { DataTypes } = require('sequelize');
const sequelize = require('../config/database')

const RestaurantModel = sequelize.define('restaurant', {
  restaurant_id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false
  },
  province_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  city_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false
  },
  address: {
    type: DataTypes.STRING,
    allowNull: false
  },
  introduce: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  delicacy: {
    type: DataTypes.TEXT
  },
  images: {
    type: DataTypes.JSON,
    allowNull: false
  },
  longitude: {
    type: DataTypes.DECIMAL(9, 6),
    allowNull: false
  },
  latitude: {
    type: DataTypes.DECIMAL(9, 6),
    allowNull: false
  },
  opening_time: {
    type: DataTypes.STRING,
    allowNull: false
  },
  price: {
    type: DataTypes.DECIMAL(10, 2),
    allowNull: false
  },
  rating: {
    type: DataTypes.DECIMAL(3, 1),
    allowNull: false
  },
  phone: {
    type: DataTypes.STRING,
    allowNull: false
  },
  type: {
    type: DataTypes.ENUM('中餐', '西餐', '特色小吃', '自助餐', '快餐'),
    allowNull: false
  },
  is_hot: {
    type: DataTypes.TINYINT,
    defaultValue: 0,
    allowNull: false
  }
}, {
  freezeTableName: true,
  tableName: 'restaurant',
  timestamps: false
})

module.exports = RestaurantModel